<template>
  <div class="preOption">


    <div>
      <p>
        <span>订单号：{{item.PRESCRIBEID}}</span>
        <span>{{item | filOrderStatus}}</span>
      </p>
      <p>
        <span>订单类型：{{item.ORDERTYPE}}</span>
        <span>{{ item.OI_PAYYBTYPE | filOrderIfyb }}</span>
      </p>
    </div>


    <div>
      <p>
        <span>{{item.OPENTIME}}</span>
        <span v-if="item.IFYBJS == 'y' && item.YBJSZT != 'k'" style="color: #ccc;">费用计算中...</span>
        <span v-else-if="item.IFYBJS == 'y' && item.YBJSZT == 'k'" style="color: #ccc;">费用：{{Number(item.PRESCRIPTION_PRICE)}}元.</span>
        <span v-else>费用：{{Number(item.PRESCRIPTION_PRICE)}}元</span>
      </p>
    </div>


    <div>
      <p v-if="item.IFYBJS == 'y' && item.YBJSZT != 'k'">
        <span>
          <nuxt-link :to="{path:'/chufang/ybjs',query:{preinfostr: JSON.stringify(item) }}" tag="a"
          >查看</nuxt-link>
        </span>
      </p>
      <p v-else>
        <span v-show="item.ORDSTATUS == '0' && item.OI_PAYYBTYPE == ''">
          <nuxt-link :to="{name:'chufang-nonePayment',query:{preinfostr:JSON.stringify(item) }}" tag="a" v-if="item.ORDSTATUS=='0'"
          >付款</nuxt-link>
        </span>
        <span v-show="item.ORDSTATUS == '0' && item.OI_PAYYBTYPE != ''">
          <nuxt-link :to="{name:'chufang-pay',query:{preinfostr:JSON.stringify(item) }}" tag="a" v-if="item.ORDSTATUS=='0'"
          >付款</nuxt-link>
        </span>
        <span v-show="item.ORDSTATUS == '3'">
          <nuxt-link :to="{path:'/chufang/unship',query:{preinfostr: JSON.stringify(item) }}" tag="a"
          >查看</nuxt-link>
        </span>
        <span v-show="item.ORDSTATUS == '4' || item.ORDSTATUS == '5'">
          <nuxt-link :to="{path:'/chufang/prescribeOrderDetail',query:{preinfostr: JSON.stringify(item) }}" tag="a" v-if="item.ORDSTATUS=='4'||item.ORDSTATUS=='5'"
          >查看</nuxt-link>&nbsp;
          <nuxt-link :to="{path:'/chufang/checkExpressInfo',query:{preinfostr: JSON.stringify(item) }}" tag="a">物流信息</nuxt-link>
        </span>
        <span v-show="item.ORDSTATUS == '4'">
          <a href="javascript:void(0);" @click="queren(item.ORDERID)">收货</a>
        </span>
        <span v-show="item.ORDSTATUS == '0'">
          <a href="#" @click="deletePay(item.ORDERID)">删除</a>
        </span>
      </p>
    </div>


  </div>
</template>

<script>
export default {
  props: ['itemjson', 'selected'],
  data() {
    return {
      orderStatus: '未付款',
      ybinfo: '医保',

      selectedShow: '',

      item: {},

      patientid: '10607', // 测试数据
      queren1: '确认收货',
      headTitle: '我的药方',
      alertText: '删除成功！',
      showAlert: false,
      list: [],
      alllist: [],
      ts: this.newStore(),
      busy: true,
      page: 1,
      loadingText: '',
      recordKey: '',
      prescribe:{}
    };
  },
  created() {
    this.item = JSON.parse(this.itemjson);
    this.selectedShow = this.selected; // 父直接传过来的参数如果用到页面中，要传递给本地变量
  },
  methods: {
    deletePay(v) {
      this.$emit('deletePayF', v);
      // this.$messagebox(`hello${v}`);
    },
    queren(v) {
      this.$emit('queren', v);
    },
  },
  filters: {
    filterks(v) {
      if (!v) return '-';
      return v;
    },
    filOrderStatus(v) {

      if (v.IFYBJS == 'y' && v.YBJSZT != 'k') {
          return '医保结算中';
      }
      
      switch (v.ORDSTATUS) {
        case '0':
          return '待付款';
        case '3':
          return '待发药';
        case '4':
          return '待收药';
        case '5':
          return '已收药';
        default:
          return '';
      }

    },
    filOrderIfyb(v) {
      switch (v) {
        case 'y':
          return '【医保】';
        case 'n':
          return '【自费】';
        default:
          return '';
      }
    }
  },
};
</script>

<style lang="stylus" scoped>
.preOption
  display flex
  flex-flow column
  justify-content flex-start
  align-content center
  div
    p
      display flex
      flex-flow row
      justify-content space-between
      align-content center
      line-height 1.5rem
      color #666
      font-size .8rem
    &:first-child /* 基本信息 */
      p
        &:first-child
          font-size 1rem
          color #111
          span
            &:last-child
              color #26a2ff
    &:nth-child(2)  /* 时间信息 */
      p
        margin-top .5rem
        &:first-child
          color #ccc
          font-size .6rem
        span
          &:last-child
            color #111
    &:nth-child(3)  /* 按扭 */
      p
        span
          a
            color #666
            border .5px solid #ccc
            padding .3rem .5rem
            border-radius 5px

</style>
